﻿using System;
using System.Windows.Data;
using System.Windows.Media;

namespace Convertor
{
    public class TemplateListBGColorConverter : IMultiValueConverter
    {
        #region IMultiValueConverter 成员

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string[] color = parameter.ToString().Split(',');
            TemplateToSaveContainer t = (TemplateToSaveContainer)values[0];
            if (t.Name == (string)values[1])
            {
                return string.IsNullOrEmpty(color[0]) ? Brushes.Transparent : new BrushConverter().ConvertFromString(color[0]) as SolidColorBrush;
            }
            else
            {
                return string.IsNullOrEmpty(color[1]) ? Brushes.Transparent : new BrushConverter().ConvertFromString(color[1]) as SolidColorBrush;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
